package fr.inserm.u915.organifooyi.model;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.MappedSuperclass;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@MappedSuperclass
public abstract class AbstractPersistentObject {
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY, generator="native")
	private Long id;
	
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="created_by")
	private User createdBy;
	
	
	
	@Column(name="creation")
	@Temporal(TemporalType.TIMESTAMP)
	private Date creation=null;
	
	protected AbstractPersistentObject()
		{
		}
	
	
	public Long getId()
	{
	return id;
	}

public void setId(Long id)
	{
	this.id = id;
	}




public Date getCreation()
	{
    return creation;
	}

	public void setCreation(Date creation)
		{
		this.creation = creation;
		}
	

	public User getCreatedBy() {
		return createdBy;
	}

	public void setCreatedBy(User createdBy) {
		this.createdBy = createdBy;
	}

	
	@Override
	public int hashCode() {
		return id==null?-1:id.hashCode();
		}
	
	@Override
	public String toString() {
		return "ID.("+id+")";
		}
	}
